{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2df80339",
   "metadata": {},
   "source": [
    "# Lesson 1: Your First AI Agent\n",
    "\n",
    "Welcome to Lesson 1.\n",
    "\n",
    "To access the `requirements.txt` file, please go to the `File` menu and select`Open...`.\n",
    "\n",
    "I hope you enjoy this course!"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bfdcabc1",
   "metadata": {},
   "source": [
    "## Setup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e8a67f41-d133-4e91-b54f-80bb3cd9a666",
   "metadata": {
    "height": 64
   },
   "outputs": [],
   "source": [
    "import os \n",
    "import pandas as pd \n",
    "from IPython.display import Markdown, HTML, display"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f4c6e550",
   "metadata": {},
   "source": [
    "## Connect to the Azure OpenAI endpoint\n",
    "\n",
    "**Note**: The pre-configured cloud resource grants you access to the Azure OpenAI GPT model. The key and endpoint provided below are intended for teaching purposes only. Your notebook environment is already set up with the necessary keys, which may differ from those used by the instructor during the filming."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "56216e12",
   "metadata": {},
   "source": [
    "```\n",
    "openai_api_version=\"2023-05-15\"\n",
    "azure_deployment=\"gpt-4-1106\"\n",
    "azure_endpoint=\"https://testadri.openai.azure.com\"\n",
    "\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "178321d6",
   "metadata": {},
   "source": [
    "## 1. Leveraging Langchain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c5e4be2b",
   "metadata": {
    "height": 149
   },
   "outputs": [],
   "source": [
    "from langchain.schema import HumanMessage\n",
    "from langchain_openai import AzureChatOpenAI\n",
    "\n",
    "model = AzureChatOpenAI(\n",
    "    openai_api_version=\"2024-04-01-preview\",\n",
    "    azure_deployment=\"gpt-4-1106\",\n",
    "    azure_endpoint=os.getenv(\"AZURE_OPENAI_ENDPOINT\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9fde1292",
   "metadata": {},
   "source": [
    "## 2. Preparing your prompt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0d145d0d-30f2-412b-822c-e23ff9bf2bc4",
   "metadata": {
    "height": 98
   },
   "outputs": [],
   "source": [
    "message = HumanMessage(\n",
    "    content=\"Translate this sentence from English \"\n",
    "    \"to French and Spanish. I like red cars and \"\n",
    "    \"blue houses, but my dog is yellow.\"\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "94f5e7b6",
   "metadata": {},
   "source": [
    "## 3. Engaging the model to receive a response"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e49e3b6d-71e8-4906-bf9c-fca78c1fbd4c",
   "metadata": {
    "height": 30
   },
   "outputs": [],
   "source": [
    "model.invoke([message])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
